rm(list=ls())
require(quanteda)
require(stringi)
source("functions.R")

toks <- readRDS("data/data_tokens.RDS")

dfmt <- dfm(tokens_lookup(toks, dict[["issue"]])) %>% 
    dfm_group()
dat <- data.frame(docid = docid(dfmt))
dat <- cbind(dat, convert(dfm_weight(dfmt, "boolean"), "data.frame"))

saveRDS(dat, "data/data_dictionary.RDS")

